#include<bits/stdc++.h>
#define ONLINE_JUDGE
#define ll long long
#define ull unsigned long long
using namespace std;

const int N = 3010;
const ll INF = 0x3f3f3f3f3f3f3f3f; 

int n, h, m;
int a[N], b[N];
ll dp[N][N]; 

void solve() {
    cin >> n >> h >> m;
    for (int i = 1; i <= n; i++)
        cin >> a[i] >> b[i];


    for (int j = 0; j <= h; j++)
        dp[0][j] = -INF;
    dp[0][h] = m;

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        bool valid = false; // 当前i是否有合法状态
        for (int j = 0; j <= h; j++) {
            dp[i][j] = -INF; // 初始化为无效状态

            // 健康击败：从前i-1的[j+a[i]]状态转移（消耗a[i]健康）
            if (j + a[i] <= h && dp[i - 1][j + a[i]] != -INF)
                dp[i][j] = max(dp[i][j], dp[i - 1][j + a[i]]); // 魔法不变

            // 魔法击败：从前i-1的[j]状态转移（消耗b[i]魔法）
            if (dp[i - 1][j] != -INF && dp[i - 1][j] >= b[i])
                dp[i][j] = max(dp[i][j], dp[i - 1][j] - b[i]);

            if (dp[i][j] != -INF)
                valid = true;
        }
        if (valid) ans = i;
        else break; // 无法击败当前怪物，退出
    }
    cout << ans << "\n";
    }

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    // 重定向输入（如有需要）
    // freopen("input.txt", "r", stdin);
#endif
    int T = 1;
    // cin >> T;
    while (T--) solve();
    return 0;
}